/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.dahg.project.istu.web.tree;

import com.dahg.project.istu.controller.bean.menu.IMenuService;
import com.dahg.project.istu.controller.model.Menu;
import com.dahg.project.istu.web.commons.UsuarioBean;
import com.dahg.project.istu.web.commons.abstracto.AbstractMantenimiento;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import org.primefaces.model.TreeNode;

/**
 *
 * @author dahg
 */
@ManagedBean
@ViewScoped
public class TreeMenuBean extends AbstractMantenimiento<Menu> {
    
    private TreeNode root;
    @ManagedProperty("#{usuarioBean}")
    private UsuarioBean usuarioBean;
    @EJB
    private IMenuService service;
    
    private TreeNode selected;
    
    @PostConstruct
    public void init() {
        refresh();
    }
    
    private void refresh() {
        TreeMenuFactory factory = new TreeMenuFactory();
        root = factory.getModel(usuarioBean.getCurrent().getRol(), service, true);
    }

    public TreeNode getRoot() {
        return root;
    }

    public void setUsuarioBean(UsuarioBean usuarioBean) {
        this.usuarioBean = usuarioBean;
    }

    public TreeNode getSelected() {
        return selected;
    }

    public void setSelected(TreeNode selected) {
        this.selected = selected;
    }

    @Override
    public void save() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void update() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void remove() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<Menu> getAll() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
    
}
